import request from '@/utils/request'

const getTicketsList = (page, limit, key) => {
  return request('/tickets/listWeb', {
    method: 'get',
    params: {
      page,
      limit,
      key
    }
  })
}

const getTicketsListByFuzzyQuery = (page, limit, key) => {
  return request('/tickets/listByFuzzyQuery', {
    method: 'get',
    params: {
      page,
      limit,
      key
    }
  })
}

const deleteTicketsList = (ticketIds) => {
  return request('/tickets/delete', {
    method: 'post',
    data: {
      ticketIds
    }
  })
}

const getTicketById = (ticketsId) => {
  return request({
    url: `/tickets/info/${ticketsId}`,
    method: 'get'
  })
}

const saveOrUpdateTicket = (ticketsId, tickets) => {
  return request(`/tickets/${!ticketsId ? 'save' : 'update'}`, {
    method: 'post',
    data: tickets
  })
}

export { getTicketsList, getTicketsListByFuzzyQuery, deleteTicketsList, getTicketById, saveOrUpdateTicket }
